#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n;

void solve() {
  rep(i, 1, 60) cout << '-';
  cout << endl;

  vector<string> words(n);
  rep(i, 0, n - 1) cin >> words[i];
  sort(words.begin(), words.end());

  vector<int> mx(n + 1, 0);
  per(i, n - 1, 0) mx[i] = max(mx[i + 1], (int)words[i].size());

  int l = 1, h = n;
  while (l <= h) {
    int mid = (l + h) >> 1;
    int c = (n + mid - 1) / mid;
    int x = (n - 1) / mid;
    int y = mx[x * mid];
    if (x * (mx[0] + 2) + y <= 60)
      h = mid - 1;
    else
      l = mid + 1;
  }
  int r = l;
  rep(i, 0, r - 1) {
    for (int j = i; j < n; j += r) {
      cout << words[j];
      if (j + r >= n)
        cout << endl;
      else {
        int cnt = mx[0] + 2 - words[j].size();
        rep(k, 1, cnt) cout << ' ';
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  while (cin >> n) {
    solve();
  }
  return 0;
}